# Copyright 2021, Régis Décamps
# SPDX-License-Identifier: BSD-3-Clause

load("@jflex_rules//cup:cup.bzl", "cup")
load("@jflex_rules//jflex:jflex.bzl", "jflex")

package(default_visibility = ["//visibility:public"])

java_library(
    name = "core",
    srcs = glob(
        ["*.java"],
    ) + [
        ":gen_parser",
        ":gen_scanner",
    ],
    visibility = ["//jflex:visibility"],
    deps = [
        "//jflex/src/main/java/jflex/base",
        "//jflex/src/main/java/jflex/chars",
        "//jflex/src/main/java/jflex/core/unicode",
        "//jflex/src/main/java/jflex/exceptions",
        "//jflex/src/main/java/jflex/io",
        "//jflex/src/main/java/jflex/l10n",
        "//jflex/src/main/java/jflex/logging",
        "//jflex/src/main/java/jflex/option",
        "//jflex/src/main/java/jflex/performance",
        "//jflex/src/main/java/jflex/scanner",
        "//jflex/src/main/java/jflex/skeleton",
        "//jflex/src/main/java/jflex/state",
        "//third_party/java_cup:runtime",
    ],
)

# Use bootstrap version defined in @jflex_rules
jflex(
    name = "gen_scanner",
    srcs = ["//jflex/src/main/jflex:LexScan.flex"],
    outputs = ["LexScan.java"],
    skeleton = "//jflex/src/main/jflex:skeleton.nested",
)

cup(
    name = "gen_parser",
    src = "//jflex/src/main/cup:LexParse.cup",
    cup_bin = "@jflex_rules//cup:cup_bin",
    interface = True,
    parser = "LexParse",
    symbols = "sym",
)
